;MathLib Include File

 INCLUDE "libraries.inc"
 UseLibrary Math







 EXTERN _Plus
 EXTERN _BoolAnd
 EXTERN _BoolOr
 EXTERN _BoolXor
 EXTERN _Minus
 EXTERN _Mult
 EXTERN _Div
 EXTERN _Rand
 EXTERN _Inc
 EXTERN _Dec

Dec MACRO first
       db     MathLib,_Dec
       dw     first
       if     first<VarA
       error  "syntax: Dec Variable"
       error  "Dec argument must be variable"
       endif
 ENDMAC



Inc MACRO first
       db     MathLib,_Inc
       dw     first
       if     first<VarA
       error  "syntax: Inc Variable"
       error  "Inc argument must be variable"
       endif
 ENDMAC

Rand MACRO first,second
       db     MathLib,_Rand
       dw     first
       dw     second
       if     second<VarA
       error  "syntax: Rand MaxValue,Variable"
       error  "Rand second argument must be variable"
       endif
 ENDMAC


Div MACRO first,second,third
       db     MathLib,_Div
       dw     first
       dw     second
 ifneq "_&third","_"
       dw     third
       if third<VarA
       error "syntax: Div Value1,Value2,Variable"
       error "Div third argument must be variable"
       endif
 else
       if     first<VarA
       error "syntax: Div Variable,Value1"
       error "Div first argument must be variable"
       endif
       dw     first
 endif
 ENDMAC



Mult MACRO first,second,third
       db     MathLib,_Mult
       dw     first
       dw     second
 ifneq "_&third","_"
       dw     third
       if     third<VarA
       error  "syntax: Mult Value1,Value2,Variable"
       error  "Mult third argument must be variable"
       endif
 else
       dw     first
       if     first<VarA
       error  "syntax: Mult Variable,Value1"
       error  "Mult first argument must be variable"
       endif
 endif
 ENDMAC


Minus MACRO first,second,third
       db     MathLib,_Minus
       dw     first
       dw     second
 ifneq "_&third","_"
       dw     third
       if     third<VarA
       error  "syntax: Minus Value1,Value2,Variable"
       error  "Minus third argument must be variable"
       endif
 else
       dw     first
       if     first<VarA
       error  "syntax: Minus Variable,Value1"
       error  "Minus first argument must be variable"
       endif
 endif
 ENDMAC


Plus MACRO first,second,third
       db     MathLib,_Plus
       dw     first
       dw     second
 ifneq "_&third","_"
       dw     third
       if     third<VarA
       error  "syntax: Plus Value1,Value2,Variable"
       error  "Plus third argument must be variable"
       endif
 else
       dw     first
       if     first<VarA
       error  "syntax: Plus Variable,Value1"
       error  "Plus first argument must be variable"
       endif
 endif
 ENDMAC

BoolAnd MACRO first,second,third

       db     MathLib,_BoolAnd
       dw     first
       dw     second
 ifneq "_&third" ,"_"
       if     third<VarA
       error  "syntax: BoolAnd Value1,Value2,Variable"
       error  "BoolAnd third argument must be variable"
       endif
       dw     third
 else
       if     first<VarA
       error  "syntax: BoolAnd Variable,Value1"
       error  "BoolAnd first argument must be variable"
       endif
       dw     first
 endif
 ENDMAC

BoolOr MACRO first,second,third

       db     MathLib,_BoolOr
       dw     first
       dw     second
 ifneq "_&third" ,"_"
       dw     third
       if     third<VarA
       error  "syntax: BoolOr Value1,Value2,Variable"
       error  "BoolOr third argument must be variable"
       endif
 else
       dw     first
       if     first<VarA
       error  "syntax: BoolOr Variable,Value1"
       error  "BoolOr first argument must be variable"
       endif
 endif
 ENDMAC

BoolXor MACRO first,second,third

       db     MathLib,_BoolXor
       dw     first
       dw     second
 ifneq "_&third" ,"_"
       if     third<VarA
       error  "syntax: BoolXor Value1,Value2,Variable"
       error  "BoolXor third argument must be variable"
       endif
       dw     third
 else
       if     first<VarA
       error  "syntax: BoolXor Variable,Value1"
       error  "BoolXor first argument must be variable"
       endif
       dw     first
 endif
 ENDMAC
